const TokenKey = 'token'

export function getToken(pure = false) {
  const token = uni.getStorageSync(TokenKey)
  return pure ? token.replace('Bearer ', '') : token
}

export function setToken(token: string) {
  return uni.setStorageSync(TokenKey, `Bearer ${token}`)
}

export function removeToken() {
  return uni.removeStorageSync(TokenKey)
}

export function clearStorage() {
  const whiteList = ['equipment']
  const res = uni.getStorageInfoSync()
  res.keys.forEach(key => {
    whiteList.includes(key) || uni.removeStorageSync(key)
  })
}
